package Collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class NewforDemo {
    public static void main(String[] args) {
        String[] array={"one","two","three","four","five"};
//        for (int i=0;i<array.length;i++){
//            System.out.println(array[i]);
//        }

        for (String str:array){//新循环
            System.out.println(str);
        }

        Collection c=new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");

//        Iterator i=c.iterator();
//        while (i.hasNext()){
//            String str=(String)i.next();
//            System.out.println(str);
//        }
        for(Object obj:c){//新循环obj代表集合中每个元素
            String str=(String)obj;
            System.out.println(str);
        }
    }
}
